package com.wangchao.administrator.zenmechi.ui.fragment.homefragment;

import android.content.Context;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.wangchao.administrator.zenmechi.bean.homebean.GoodsHotListBean;
import com.wangchao.administrator.zenmechi.bean.homebean.Mainbean;
import com.wangchao.administrator.zenmechi.bean.homebean.NearbyMerchantListBean;
import com.wangchao.administrator.zenmechi.image.MyListView;

import java.util.List;
import java.util.Map;

import rx.Subscriber;

/**
 * Created by Administrator on 2016/10/17.
 */
public class HomePresenter implements HomeContract.Presenter {
    private HomeContract.Model model;
    private HomeContract.View view;

    public HomePresenter(HomeContract.View view) {
        this.model =new HomeModel();
        this.view = view;
    }
    @Override
    public void getMainBean(String string, Map<String, String> map){
        model.getMainItem(new Subscriber<Mainbean>() {

            @Override
            public void onCompleted() {
            }

            @Override
            public void onError(Throwable e) {
            view.onFail((Exception) e);
            }

            @Override
            public void onNext(Mainbean mainbean) {
                view.onSuccess(mainbean);
            }
        },string,map);
    }
    @Override
    public List<ImageView> setListView(List<GoodsHotListBean> goodsHotList, Context context){
     return    model.addlistvewimage(goodsHotList,context);

    }
    @Override
    public void setListViewAdapter(MyListView myListViewone, Context context, List<GoodsHotListBean> goodsHotList){
        model.setListViewAdapter(myListViewone,context,goodsHotList);
    }
    @Override
    public void setListViewAdaptertwo(MyListView myListViewone, Context context, List<NearbyMerchantListBean> nearbyMerchantList){
        model.setListViewAdaptertwo(myListViewone,context,nearbyMerchantList);
    }
    @Override
    public void lodpic(ImageView imageView,Context context,String url){
        Glide.with(context).load(url).into(imageView);
    }
}
